//
//  AccountService.m
//  Cabs
//
//  Created by Joey on 2018/5/30.
//  Copyright © 2018年 Happyev. All rights reserved.
//

#import "AccountService.h"
#import <AdSupport/AdSupport.h>

@implementation AccountService

/**
 登录
 
 @param phone 手机号
 @param phoneCode 验证码
 @param device 设备 Ud
 @return 用户个人信息
 */
+(RACSignal *)loadLogin:(NSString*)phone phoneCode:(NSString*)phoneCode reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,userLogin];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"phone"] = phone;
    param[@"phoneCode"] = phoneCode;
    param[@"device"] = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    param[@"phoneCode"] = phoneCode;
    param[@"userType"] = @"0";
    param[@"device"] = @"iOS";

    return  [self postWithUrl:url param:param reponseObjctClass:reponseObjctClass];
}



/**
 退出登录
 
 @param  token
 @return 成功 OR 失败
 */

+(RACSignal *)loaduserLoginOut{
    NSString *url = [NSString stringWithFormat:@"%@%@%@",Main_Token_Model_MANAGER.RootUrl,userLoginOut,kUSER_INFO_MANAGER.token];
    
    return [self deleteWithUrl:url param:nil Api_key:nil reponseObjctClass:nil];
}





/**
 保存头像
 @param  filePath  图片路径
 @return 版本信息
 */
+(RACSignal *)loadsaveUserAvatar:(NSString*)filePath{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,saveUserAvatar];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"filePath"] = filePath;
    
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}


/**
 获取系统头像
 @return 版本信息
 */
+(RACSignal *)loadgetSystemAvatar:(NSString*)fileType{
    
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,getSystemAvatar];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"fileType"] = fileType;
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
    
}


/**
 获取图片上传鉴权
 @param  path  图片路径
 @return sign 鉴权
 */
+(RACSignal *)loadgetgetSign:(NSString*)path{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,getSign];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"path"] = path;
    param[@"oneceFlg"] = @"true";
    
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}


/**
 保存用户信息
 @param  nickName  图片路径
 @return sign 成功
 */
+(RACSignal *)loadsaveUserInfo:(NSString*)nickName{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,saveUserInfo];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"nickName"] = nickName;
    
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}





/**
 发送验证码
 
 @param phone 手机号
 @return 成功 OR 失败
 */
+(RACSignal *)loadSendSms:(NSString*)phone{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,sendSms];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"phone"] = phone;
    
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}

/**
 用户信息
 
 @return 成功 OR 失败
 */
+(RACSignal *)getUserInfo{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,getUserInfo];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}


/**
 登录（新版）
 
 @param principal 账号
 @param credential 用户凭证，密码
 @param authMethod 短信登陆是，请填写SMS_CODE。其它登陆方式可不填
 @return 用户个人信息
 */
+(RACSignal *)loadLoginForPassword:(NSString*)principal credential:(NSString*)credential authMethod:(NSString*)authMethod reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,accountlogin];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"principal"] = principal;
    param[@"credential"] = credential;
    param[@"terminal"] = @"DBB";
    param[@"authMethod"] = authMethod;
    param[@"singleClient"] = @"false";
    param[@"autoRenewal"] = @"true";

    return  [self postWithUrl:url param:param reponseObjctClass:nil];
    
}



/**
 忘记密码(new)
 
 @param principal 账号
 @param credential 用户凭证，密码
 @param password 账号密码
 @return 用户个人信息
 */
+(RACSignal *)loadLoginForforget:(NSString*)principal credential:(NSString*)credential password:(NSString*)password reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,accountforget];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"principal"] = principal;
    param[@"credential"] = credential;
    param[@"password"] = password;
    param[@"terminal"] = @"DBB";
    
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}



/**
 更新帐号信息(new)
 
 @param userName 账号
 @param nickName 名字
 @param phone 电话
 @param password 密码
 @param email 邮箱
 
 @return 用户个人信息
 */
+(RACSignal *)loadLoginForupdate:(NSString*)userName nickName:(NSString*)nickName phone:(NSString*)phone password:(NSString*)password email:(NSString*)email reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,accountupdate];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"userName"] = userName;
    param[@"nickName"] = nickName;
    param[@"phone"] = phone;
    param[@"password"] = password;
    param[@"email"] = email;
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}


/**
 验证码(new)
 @param principal 账号自动判断类型
 @return 用户个人信息
 */
+(RACSignal *)loadLoginForsendCode:(NSString*)principal ticket:(NSString*)ticket randstr:(NSString*)randstr reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,accountsendCode];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"principal"] = principal;
    param[@"ticket"] = ticket;
    param[@"randstr"] = randstr;

    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}

/**
 注册(new)
 
 @param principal 账号
 @param credential 用户凭证，密码
 @param authMethod 短信登陆是，请填写SMS_CODE。其它登陆方式可不填
 @return 用户个人信息
 */
+(RACSignal *)loadLoginForregistry:(NSString*)principal credential:(NSString*)credential password:(NSString*)password reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,accountregistry];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"principal"] = principal;
    param[@"credential"] = credential;
    param[@"password"] = password;
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}

/**
 拉黑列表
 */
+(RACSignal *)loadUserRepelList:(NSInteger)page reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,userRepelList];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"page"] =  [NSString stringWithFormat:@"%ld",page+1];
    param[@"size"] = @"10";
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}

/**
 添加拉黑
 */
+(RACSignal *)loadUserRepelAdd:(NSString*)repelId reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,userRepelAdd];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"repelId"] =  repelId;
    return  [self postWithUrl:url param:param reponseObjctClass:nil];
}

/**
 取消拉黑
 */
+(RACSignal *)loadUserRepelDelete:(NSString*)repelId reponseObjctClass:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@/%@",Main_Token_Model_MANAGER.RootUrl,userRepelAdd,repelId];
    return [self deleteWithUrl:url param:nil Api_key:nil reponseObjctClass:nil];
}

/**
 peizhi
 */
+(RACSignal *)loadUserCreateppp:(Class)reponseObjctClass{
    NSString *url = [NSString stringWithFormat:@"%@%@",Main_Token_Model_MANAGER.RootUrl,createppp];
    return [self getWithUrl:url param:nil reponseObjctClass:nil];
}

@end
